package com.ylbh.modules.sign.controller;

import com.ylbh.common.annotation.SysLog;
import com.ylbh.common.pojo.sign.dto.SignPrizeDTO;
import com.ylbh.common.pojo.sign.dto.SignTurntableDTO;
import com.ylbh.common.pojo.sign.vo.ShoppingSigninPrizeVO;
import com.ylbh.common.utils.CommonResult;
import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.utils.Ref;
import com.ylbh.modules.sign.entity.ShoppingSigninPrize;
import com.ylbh.modules.sign.entity.ShoppingSigninTurntableInfo;
import com.ylbh.modules.sign.service.ShoppingSignPrizeService;
import com.ylbh.modules.sign.service.ShoppingSignTurntableService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author; wjc
 * @date: 2019/12/17
 */
@RestController
@RequestMapping("prize")
public class ShoppingSignPrizeController {

    @Autowired
    private ShoppingSignPrizeService shoppingSignPrizeService;

    @RequestMapping("uploadPrizeImg")
    public CommonResult<String> uploadPrizeImg(MultipartFile file, HttpServletRequest request) {
        String url = shoppingSignPrizeService.uploadPrizeImg(file, request);
        System.out.println(url);
        return Ref.ok(url);
    }

    @RequestMapping("addPrizeInfo")
    public CommonResult addPrizeInfo(@RequestBody SignPrizeDTO signPrizeDTO ) {
        shoppingSignPrizeService.addPrizeInfo(signPrizeDTO);
        return Ref.ok();
    }

    @SysLog("获取活动信息ById")
    @RequestMapping("prizeInfoById/{id}")
    public CommonResult<ShoppingSigninPrizeVO> getPrizeInfoById(@PathVariable(value = "id") Integer id) {
        ShoppingSigninPrizeVO  prizeInfo = shoppingSignPrizeService.getPrizeInfoById(id);
        return Ref.ok(prizeInfo);
    }

    @SysLog("根据ID修改活动信息")
    @ApiOperation("根据ID修改活动信息")
    @RequestMapping("modifyPrizeInfoById")
    public CommonResult modifyTurntableById(@RequestBody SignPrizeDTO signPrizeDTO) {
        shoppingSignPrizeService.modifyPrizeInfoById(signPrizeDTO);
        return  Ref.ok();
    }

    /*@SysLog("根据ID修改活动信息")
    @ApiOperation("根据ID修改活动信息")
    @RequestMapping("prizeInfoById")
    public CommonResult modifyTurntableById(@RequestBody SignPrizeDTO signPrizeDTO) {
        shoppingSignTurntableService.modifyTurntableById(signTurntableDTO);
        return  Ref.ok();
    }*/
}
